package com.example.myapplication.model;

import android.util.Log;

import com.example.myapplication.base.BaseModel;
import com.example.myapplication.bean.SquaseBean;
import com.example.myapplication.net.ResultCallBack;
import com.example.myapplication.util.HttpUtil;
import com.example.myapplication.util.ResultSubscriber;
import com.example.myapplication.util.RxUtils;

public class SquareModel extends BaseModel {
    public void getSquareData(int page,final ResultCallBack<SquaseBean> resultCallBack) {
        addDisposable(
                HttpUtil.getInstance()
                .getSquareService()
                .getData(page)
                .compose(RxUtils.<SquaseBean>ttFlowableTransformer())
                .subscribeWith(new ResultSubscriber<SquaseBean>() {
                    @Override
                    public void onNext(SquaseBean squaseBean) {
                        resultCallBack.onSuccess(squaseBean);
                        Log.d(TAG, "onNext: "+squaseBean);
                    }
                })
        );
    }

    private static final String TAG = "SquareModel";
}
